<div id="category_selector">
<?php
if(!isset($addPage))
{
	$addPage = true;
}
$label = "Categories";
$fieldOptions = array("div"=>"required input text",'empty'=>"-Select-","label"=>$label,"options"=>$categories,"type"=> "select");
if(cr("ListingConfig.allow_multiple_categories"))
{
	if(($addPage == true) || ($addPage == false && isset($allowMultipleCategories) && $allowMultipleCategories))
	{
		unset($fieldOptions['empty']);
		$fieldOptions['type'] = "multipleSelect";
	}
}
echo $form->input("Listing.categories",$fieldOptions);
if($addPage && $step > 1 )
{
	echo $html->link("Change category","javascript:void(0)",array("id"=>"change_category"));
}
?>
</div>	
<?php if($addPage){?>
<script>
	$(document).ready(function(){
		var submitButton = $("#listing_form").find("input[type='submit']");
		submitButton.click(function(){
			$("#ListingCategories").attr("disabled",false);
		})
		<?php if($step > 1){?>
			$("#ListingCategories").attr("disabled",true);
		<?php }else{ ?>
			
			submitButton.attr("value","<?php echo __("Next")?>");
		<?php }?>
		$("#change_category").click(function(){
			$("#ListingCategories").attr("disabled",false);
			$("#category_selector").parent().children().not($("#category_selector")).hide();
			submitButton.attr("value","Change");
			$("#ListingStep").val(1);
			return false;
		})
	})
	
</script>	
<?php } ?>